package com.dlmu.MapDemo;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

public class MapDemo1 {
    public static void main(String[] args) {
        //多态
        Map<String,String> map=new HashMap<>();
        map.put("1","1");
        map.put("2","2");
        map.put("3","3");
        map.put("4","1111");
        String str1=map.get("4");
        System.out.println(str1);
        //单独获取双列集合中的键
        Set<String> s=map.keySet();
        Iterator<String> it = s.iterator();
        while(it.hasNext()){
            String str=it.next();
            System.out.println(str);
        }

        s.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });

        System.out.println(map);
    }
}
